/* 
 * Copyright (c) 2010 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.enterprise.gsa.util;

import com.google.gdata.util.NotImplementedException;

import static java.lang.System.console;
import static java.lang.System.out;

/**
 * A utility class that prompts a user for his/her password via the console/stdout
 *  
 * @author todd.re...@gmail.com (Todd)
 */
public class PasswordPrompt {

  /*
   * Private constructor so that this can't be instantiated. 
   */
  private PasswordPrompt () {}
  
  /**
   * Prompts the user for a password via {@code stdout}.
   * 
   * @param promptMsg A string to print asking the user for a password
   * @return the password the user entered
   */
  public static String getPasswordViaConsole(String promptMsg) {
    char[] pw;
    out.print(promptMsg);
    pw = console().readPassword();
    out.println();
    return String.valueOf(pw);
  }
  
  public static String getPasswordViaSwing() throws NotImplementedException {
    throw new NotImplementedException("method is not yet implemented.");
  }
}
